home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / lib / partman / choose_partition / 60partition_tree / do_option < prev   
Encoding:
Text File  |  2009-04-19  |  2.9 KB  |  114 lines

  1. #!/bin/sh -e
  2.  
  3. set -e
  4.  
  5. . /lib/partman/lib/base.sh
  6.  
  7. dev=${1%//*}
  8. id=${1#*//}
  9.  
  10. cd $dev
  11. device=$(humandev $(cat device))
  12.  
  13. # If the user wants to modify a device or partition
  14. # the device may not be locked
  15. if [ -e "$dev/locked" ]; then
  16.     locked=$(cat "$dev/locked")
  17.     db_subst partman-base/devicelocked DEVICE "$device"
  18.     db_subst partman-base/devicelocked MESSAGE "$locked"
  19.     db_set partman-base/devicelocked false
  20.     db_input critical partman-base/devicelocked
  21.     db_capb
  22.     db_go || true
  23.     db_capb backup align
  24.     exit 0
  25. fi
  26.  
  27. # Two scenarios to check for here:
  28. # 1) If the user wants to modify a partition - it may not be locked
  29. # 2) If the user wants to modify a device - none of its partitions may be locked
  30. open_dialog PARTITIONS
  31. while { read_line num tmpid size type fs path name; [ "$tmpid" ]; }; do
  32.     if [ -n "$id" ]; then
  33.         [ "$id" = "$tmpid" ] || continue
  34.     fi
  35.  
  36.     if [ -e "$dev/$tmpid/locked" ]; then
  37.         locked=$(cat "$dev/$tmpid/locked")
  38.         db_subst partman-base/partlocked DEVICE "$device"
  39.         db_subst partman-base/partlocked PARTITION "$num"
  40.         db_subst partman-base/partlocked MESSAGE "$locked"
  41.         db_set partman-base/partlocked false
  42.         db_input critical partman-base/partlocked
  43.         db_capb
  44.         db_go || true
  45.         db_capb backup align
  46.         close_dialog
  47.         exit 0
  48.     fi
  49. done
  50. close_dialog
  51.  
  52.  
  53. if [ -z "$id" ]; then
  54.     # ask_user /lib/partman/storage_device "$dev" "$id" || true
  55.     open_dialog GET_LABEL_TYPE
  56.     read_line x
  57.     close_dialog
  58.     # do not try to create partition table on sw RAID device or LVM LV
  59.     if [ "$x" = loop ]; then
  60.         exit 0
  61.     fi
  62.     mklabel=$(echo /lib/partman/storage_device/[0-9][0-9]label/do_option)
  63.     [ -x "$mklabel" ] || exit 0
  64.     $mklabel label "$dev" || true
  65.     exit 0
  66. else
  67.     open_dialog PARTITION_INFO $id
  68.     read_line num id size type fs path name
  69.     close_dialog
  70.     [ "$id" ] || exit 0
  71.     case "$fs" in
  72.         free)
  73.         ask_user /lib/partman/free_space "$dev" "$id" || true
  74.         ;;
  75.         *)
  76.         while true; do
  77.             set +e
  78.             device="$(humandev $(cat device))"
  79.             db_subst partman/active_partition DEVICE "$device"
  80.             db_subst partman/active_partition PARTITION "$num"
  81.             if [ -f  $id/detected_filesystem ]; then
  82.                 filesystem=$(cat $id/detected_filesystem)
  83.                 RET=''
  84.                 db_metaget partman/filesystem_long/"$filesystem" description || RET=''
  85.                 if [ "$RET" ]; then
  86.                     filesystem="$RET"
  87.                 fi
  88.                 db_subst partman/text/there_is_detected FILESYSTEM "$filesystem"
  89.                 db_metaget partman/text/there_is_detected description
  90.             else
  91.                 db_metaget partman/text/none_detected description
  92.             fi
  93.             db_subst partman/active_partition OTHERINFO "${RET}"
  94.  
  95.             if [ -f $id/detected_filesystem ] && [ -f $id/format ]; then
  96.                 db_metaget partman/text/destroyed description
  97.                 db_subst partman/active_partition DESTROYED "${RET}"
  98.             else
  99.                 db_subst partman/active_partition DESTROYED ''
  100.             fi
  101.  
  102.             ask_user /lib/partman/active_partition "$dev" "$id"
  103.             exitcode="$?"
  104.             if [ "$exitcode" -ge 128 ] && [ "$exitcode" -lt 192 ]; then
  105.                 exit "$exitcode" # killed by signal
  106.             elif [ "$exitcode" -ge 100 ]; then
  107.                 break
  108.             fi
  109.             set -e
  110.         done
  111.         ;;
  112.     esac
  113. fi
  114.